<?php /* Smarty version 2.6.20, created on 2016-07-19 15:21:40
         compiled from tax_insurance_fee_setting.html */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('modifier', 'date_format', 'tax_insurance_fee_setting.html', 51, false),)), $this); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>发货单模板</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../script/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="../script/jquery.ui.js"></script>
<script type="text/javascript" src="../script/dialog/dialog.js" id="dialog_js"></script>
</head>
<body>
<div class="container">
    <div class="flow">
        <div class="itemtitle">
            <h3>税费保险设置</h3>
            <ul>
                <li <?php if ($_GET['operation'] == ''): ?>class="current"<?php endif; ?>><a href="?m=<?php echo $_GET['m']; ?>
&s=<?php echo $_GET['s']; ?>
"><span>管理</span></a></li>
            </ul>
		</div>
    </div>
    <div class="h35"></div>
    
    <form action="" method="post" id="form" name="form">
    <input name="delete_ids" id="delete_ids" type="hidden" value=""/>
    <table class="table">
    	<thead>
        <tr>
            <th colspan="99" class="partition">
            <ul class="button">
                <li class="button">
                    <a class="a_button" id="add_rule" href="javascript:void();">添加</a>
                </li>
            </ul>
            </th>
        </tr>
        </thead>
        <tbody>
            <tr id="tax_table" class="header">
                <th width="50">ID</th>
                <th width="150">税费区间</th>
                <th width="100">保险费</th>
                <th width="60">创建时间</th>
                <th width="60">创建人</th>
                <th width="30"></th>
            </tr>
            <?php $_from = $this->_tpl_vars['de']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['key'] => $this->_tpl_vars['list']):
?>
            <tr id="data-line-<?php echo $this->_tpl_vars['key']+1; ?>
" class="data-line" data-id="<?php echo $this->_tpl_vars['key']+1; ?>
">
                <td id="list-id<?php echo $this->_tpl_vars['key']+1; ?>
"><?php echo $this->_tpl_vars['list']['id']; ?>
</td>
                <td data-id="<?php echo $this->_tpl_vars['key']+1; ?>
"><input type="text" id="tax_price_low<?php echo $this->_tpl_vars['key']+1; ?>
" name="tax_price_low[<?php echo $this->_tpl_vars['key']+1; ?>
]" value="<?php echo $this->_tpl_vars['list']['tax_price_low']; ?>
" <?php if ($this->_tpl_vars['key'] != 0): ?>readonly<?php endif; ?> /> —— <input type="text" id="tax_price_high<?php echo $this->_tpl_vars['key']+1; ?>
" name="tax_price_high[<?php echo $this->_tpl_vars['key']+1; ?>
]" class="tax_price_high" value="<?php echo $this->_tpl_vars['list']['tax_price_high']; ?>
"/></td>
                <td><input type="text" id="insurance_fee<?php echo $this->_tpl_vars['key']+1; ?>
" name="insurance_fee[<?php echo $this->_tpl_vars['key']+1; ?>
]" value="<?php echo $this->_tpl_vars['list']['insurance_fee']; ?>
"/></td>
                <td><?php echo ((is_array($_tmp=$this->_tpl_vars['list']['create_time'])) ? $this->_run_mod_handler('date_format', true, $_tmp, "%Y-%m-%d<br>%H:%M:%S") : smarty_modifier_date_format($_tmp, "%Y-%m-%d<br>%H:%M:%S")); ?>
</td>
                <td><?php echo $this->_tpl_vars['list']['create_user']; ?>
</td>
                <td><a onclick="delete_l(this);" id="delete_button<?php echo $this->_tpl_vars['key']+1; ?>
" data-id="<?php echo $this->_tpl_vars['key']+1; ?>
" href="javascript:void(0);"><?php echo $this->_tpl_vars['delimg']; ?>
</a></td>
            </tr>
            <?php endforeach; else: ?>
            <tr class="no-data">
                <td class="norecord" colspan="99"><i></i><span>暂无符合条件的数据记录</span></td>
            </tr>
            <?php endif; unset($_from); ?>
        </tbody>
    </table>
    <input type="hidden" name="act" value="submit" />
    <input type="submit" value="提交" />
    </form>
    
</div>
</body>
<script>
$(function(){
	$('#add_rule').click(function(){//添加一行
		var data_line = $('.data-line');
		var num = data_line.size();
		if(!num){
			var tax_tr = '            <tr id="data-line-1" class="data-line" data-id="1">'
                +'<td id="list-id1">1</td>'
                +'<td data-id="1"><input type="text" id="tax_price_low1" name="tax_price_low[1]" value="0" /> —— <input type="text" id="tax_price_high1" name="tax_price_high[1]" class="tax_price_high" value="0"/></td>'
                +'<td><input type="text" id="insurance_fee1" name="insurance_fee[1]" value="0"/></td>'
                +'<td></td>'
                +'<td></td>'
                +'<td><a onclick="delete_l(this);" id="delete_button1" data-id="1" href="javascript:void(0);"><?php echo $this->_tpl_vars['delimg']; ?>
</a></td>'
            +'</tr>';
			$('#tax_table').after(tax_tr);
			if($('.no-data').length){
				$('.no-data').remove();
			}
			return false;
		}
		var mClone = data_line.eq(num-1).clone(true);

		var idNum = parseInt(data_line.eq(num-1).attr('data-id'))+1;
		mClone.attr('id',"data-line-"+idNum);
		mClone.attr('data-id',idNum);
		
		var last_tax_price_high = mClone.find("input[id^='tax_price_high"+(idNum-1)+"']").val();
		mClone.find("input[id^='tax_price_low"+(idNum-1)+"']").attr('id','tax_price_low'+idNum).attr('name','tax_price_low['+idNum+']').attr('readonly','readonly').val(parseInt(last_tax_price_high)+1);
		mClone.find("input[id^='tax_price_high"+(idNum-1)+"']").attr('id','tax_price_high'+idNum).attr('name','tax_price_high['+idNum+']').val(parseInt(last_tax_price_high)+100).parent().attr('data-id',idNum);
		mClone.find("input[id^='insurance_fee"+(idNum-1)+"']").attr('id','insurance_fee'+idNum).attr('name','insurance_fee['+idNum+']').val('0');
		mClone.find("a[id^='delete_button"+(idNum-1)+"']").attr('id','delete_button'+idNum).attr('data-id',idNum);
		
		var rdid = parseInt(mClone.find("td[id^='list-id"+(idNum-1)+"']").html());
		mClone.find("td[id^='list-id"+(idNum-1)+"']").attr('id','list-id'+idNum).html(rdid+1);
		
		$("#data-line-"+(idNum-1)).after(mClone);
	});
	
	//输入税费
	$('.tax_price_high').blur(function(){
		var _this = $(this);
		var data_id = parseInt(_this.parent().attr('data-id'));
		var data_line_num = $('.data-line').size();
		
		if(data_id==1){
			if(parseInt(_this.val())<=parseInt($('#tax_price_low1').val())){
				alert('税费区间输入不正确，右边大于左边');
				_this.focus();
				return false;
			}
		}
		
		for(var i = data_id+1;i <= data_line_num; i++){
			var tax_price_high = parseInt($('#tax_price_high'+(i-1)).val());
			$('#tax_price_low'+i).val(tax_price_high+1);
			$('#tax_price_high'+i).val(tax_price_high+100);
		}
	});
});

function delete_l(o)
{
	if(confirm('确认删除？')){
		var _this = $(o);
		var dataId = _this.attr('data-id');
		if(dataId>0){
			var deleteStr = $('#delete_ids');
			deleteStr.val(deleteStr.val()+dataId+',');
			$('#data-line-'+dataId).remove();
		}else{
			$('#data-line').remove();
		}
	}
	return false;
}
</script>
</html>